package com.chey.service.impl;

import com.chey.dao.DfieDao;
import com.chey.pojo.META;
import com.chey.pojo.dfdl.*;
import com.chey.pojo.dfie.MSG24;
import com.chey.service.DfieService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * @author JanYao
 * @version 0.1
 */
@Service
public class DfieServiceImpl implements DfieService {

    @Autowired
    private DfieDao dfieDao;

    @Override
    public void insert(MSG24 msg) {

        String dfie_uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();

        dfieDao.addMeta(dfie_uuid, msg.getMeta());

        dfieDao.addMSG(dfie_uuid);

        for (ARPT arpt : msg.getData().getARPT()) {
            dfieDao.addArpt(dfie_uuid, arpt);
        }

        for (SFLT sflt : msg.getData().getSflt()) {
            dfieDao.addSflt(dfie_uuid, sflt);
        }

        DFLT dflt = msg.getData();
        dfieDao.addDflt(dfie_uuid, dflt, dflt.getCkls(), dflt.getTMCD());


    }

}
